package com.qc.fight.example.mongo;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.WriteResult;

public class MongoDBTest {

	public static void main(String[] args) {
		Mongo mongo = new Mongo("192.168.50.128", 27017);
		DB db = mongo.getDB("fight");
		DBCollection collection = db.getCollection("stu");
		
		long start = System.currentTimeMillis();
		for (int i = 0; i < 2000000; i++) {
			BasicDBObject documents = new BasicDBObject();
			//documents.put("_id", i);
			documents.put("value", "第"+i+"个");
			collection.insert(documents);
		}
		long end = System.currentTimeMillis();
		System.out.println((end - start) / 1000 + "==" + start + "==" + end);
		//System.out.println(result.getN());
		//System.out.println(result.getUpsertedId());
		//System.out.println(result.isUpdateOfExisting());
	}
}
